<template>
	<div class="qualityquery_middle">
		<!--分析查询高中部-->
		<Row style="margin-top: 20px;margin-bottom: 20px;">
	        <Col span="6">
	        	<span>届别：</span>
				<Select v-model="sectorSelect" style="width:150px" @on-change="sectorSelectChange">
			        <Option v-for="item in sectorList" :value="item.value" :key="item.value">{{ item.label }}</Option>
			    </Select>
	        </Col>
	        <Col span="6">
	        	<span>年级：</span>
				<Select v-model="gradeSelect" style="width:150px" @on-change="gradeSelectChange">
			        <Option v-for="item in gradeList" :value="item.value" :key="item.value">{{ item.label }}</Option>
			    </Select>
	        </Col>
	        <Col span="6">
	        	<span>学年：</span>
				<Select v-model="studyYearSelect" style="width:150px" @on-change="studyYearSelectChange">
			        <Option v-for="item in studyYearList" :value="item.value" :key="item.value">{{ item.label }}</Option>
			    </Select>
	        </Col>
	    </Row>
	    <div style="width: 100%;height: 20px;background-color: #ebedf0;"></div>
	    <Row style="text-align: left;margin-top: 41px;">
			<span style="border-left: 5px solid #517EDB;font-size: 14px;"></span>
			<span style="font-size: 18px;margin-left: 10px;">考试列表</span>
		</Row >
	    <!--<Row >
	        <Col span="10" style="text-align: left;margin-top:15px;font-size: 18px;">
	        	<span>考试列表</span>
	        </Col> 
	    </Row>-->
	    <div style="padding: 0px 20px 20px 20px;">
	        	<Row v-for="item in testList" :key="item.performanceId" style="margin-top:15px;text-align: left;">   			
			        <Col span="24" >
			        	<Card>
					        <Row >   			
			        			<Col span="24">
						        	{{item.examName}}
			        			</Col>			        
							</Row>
							<Row style="margin-top:10px;text-align: left;">   			
			        			<Col span="6">
						        	入学年份：{{item.enrolYear}}
			        			</Col>
			        			<Col span="4">
						        	年级：{{item.gradeName}}
			        			</Col>
			        			<Col span="6">
						        	学年：{{item.schoolYear}}
			        			</Col>
			        			<!--<Col span="4">
						        	学期：上学期
			        			</Col>-->
			        			<Col span="6">
						        	时间：{{item.examDate}}
			        			</Col>
			        			<Col span="2">
			        				<Tooltip content="查看详细数据" theme="light">
						        		<Button type="ghost" shape="circle" icon="ios-keypad" @click="goExamInfo(item.analysisId,item.examName,item.enrolYear,item.schoolYear,item.gradeName,item.examDate)"></Button>
						        	</Tooltip>
						        	<!--<Tooltip content="删除此数据" theme="light">
						        		<Button type="ghost" shape="circle" icon="trash-a" @click="deldata(item.performanceId)"></Button>
						        	</Tooltip>-->
			        			</Col>
							</Row>
					    </Card>
			        </Col>	
				</Row> 
		    </div>
		    <Page style="text-align: center;margin-top:15px;" :current="current" :total="recordCount" @on-change="pageChange"/>
	</div>
</template>

<script>
	import api from "@/components/js/Apidomain.js"
	import { setsessionstorage,getsessionstorage } from '@/components/js/Localstorage'
	export default{
		data(){
			return{
				sectorSelect:"",
				gradeSelect:"",
				studyYearSelect:"",
				
				sectorList:[
					{value: '1',label: '2017'},
					{value: '2',label: '2018'},
					{value: '3',label: '2019'}
				],
				gradeList:[
					{value: '1',label: '2017'},
					{value: '2',label: '2018'},
					{value: '3',label: '2019'}
				],
				studyYearList:[
					{value: '1',label: '2017'},
					{value: '2',label: '2018'},
					{value: '3',label: '2019'}
				],
				testList:[],
				recordCount:0,				//总条数
				current:1,					//页码
			}
		},
		created(){
			this.getSectorlist()
		},
		methods:{
			pageChange:function(value){
        		this.current = value;
        		this.getcalculationlist()
        	},
			//获取界别选择列表
			getSectorlist:function(){
//         		this.gradelistshow = true;
           		var self = this;
            	let url = api.apidomain+'/tqes/web/squaAnalysisScoreQuery/getPeriod';
            	this.$http.post(url, {"type":"Middle"}).then(function(response) {
					if(response.data.success == true){
//						////console.log(response.data.data)
						self.sectorList = response.data.data
						if(self.sectorList.length != 0){
							self.sectorSelect = self.sectorList[0].value;
							self.getgradelist();
						}
		            }else if(response.data.success == false){
		            		self.$Message.error({
								content: response.data.msg,
								duration: 10,
								closable: true
							});
		            	}
					})
					.catch(function(error) {
						self.$Message.error({
							content: '系统发生错误：错误码00263',
							duration: 10,
							closable: true
						});
					});
           	},
           	sectorSelectChange:function(){
           		this.getgradelist()
           	},
           	//获取年级选择列表
			getgradelist:function(){
//         		this.gradelistshow = true;
           		var self = this;
            	let url = api.apidomain+'/tqes/web/squaAnalysisScoreQuery/getGradeByPeriod';
            	this.$http.post(url, {"type":"Middle","period":this.sectorSelect}).then(function(response) {
					if(response.data.success == true){
//						////console.log(response.data.data)
						self.gradeList = response.data.data
						if(self.gradeList.length != 0){
							self.gradeSelect = self.gradeList[0].value;
							self.getStudyYearList()
						}
		            }else if(response.data.success == false){
		            		self.$Message.error({
								content: response.data.msg,
								duration: 10,
								closable: true
							});
		            	}
					})
					.catch(function(error) {
						self.$Message.error({
							content: '系统发生错误：错误码00264',
							duration: 10,
							closable: true
						});
					});
           	},
           	gradeSelectChange:function(){
           		this.getStudyYearList()
           	},
			//获取学年选择列表
           	getStudyYearList:function(){
           		var self = this;
            	let url = api.apidomain+'/tqes/web/squaAnalysisScoreQuery/getQuerySchoolYearSelect';
            	this.$http.post(url,{"gradeId":this.gradeSelect}).then(function(response) {
					if(response.data.success == true){
//						////console.log(response.data.data)
						self.studyYearList = response.data.data
						if(self.studyYearList.length != 0){
							self.studyYearSelect = self.studyYearList[0].value;
							self.current = 1;
							self.getcalculationlist()
						}
		            }else if(response.data.success == false){
		            		self.$Message.error({
								content: response.data.msg,
								duration: 10,
								closable: true
							});
		            	}
					})
					.catch(function(error) {
						self.$Message.error({
							content: '系统发生错误：错误码00265',
							duration: 10,
							closable: true
						});
					});
           	},
           	studyYearSelectChange:function(){
           		this.current = 1;
           		this.getcalculationlist()
           	},
           	getcalculationlist:function(){
           		
           		let sessionroleid = getsessionstorage('roleid');
           		var self = this;
       			var senddata = {
					type:"Middle",						
					gradeId:this.gradeSelect,						
					schoolYearStart:this.studyYearSelect,	
					current:this.current,						//当前页数
					pageSize:"10"						//每页显示行数
           		}
            	let url = api.apidomain+'/tqes/web/squaAnalysisScoreCalculation/getAlreadySquaExamInfo';
            	this.$http.post(url, senddata).then(function(response) {
					if(response.data.success == true){
						
						////console.log(response.data.data)
						self.testList = response.data.data.items
						
		            }else if(response.data.success == false){
		            		self.$Message.error({
								content: response.data.msg,
								duration: 10,
								closable: true
							});
		            	}
					})
					.catch(function(error) {
						self.$Message.error({
							content: '系统发生错误：错误码00266',
							duration: 10,
							closable: true
						});
					});
           	},
			goExamInfo:function(analysisId,examName,enrolYear,schoolYear,gradeName,examDate){
				setsessionstorage('quality_middle_gradeId',this.gradeSelect);
				setsessionstorage('quality_middle_analysisId',analysisId);
				setsessionstorage('quality_middle_studyYearSelect',this.studyYearSelect);
				setsessionstorage('quality_middle_examName',examName);
				setsessionstorage('quality_middle_enrolYear',enrolYear);
				setsessionstorage('quality_middle_schoolYear',schoolYear);
				setsessionstorage('quality_middle_gradeName',gradeName);
				setsessionstorage('quality_middle_examDate',examDate);
        		this.$router.push({name:'examInfoMiddle'})
			}
		}
	}
</script>

<style lang="css" scoped>
	.qualityquery_middle >>> .ivu-card-body{
		padding: 12px 15px;
		background-color: #f7f7f7;
	}
</style>